﻿using System;
using System.Windows.Data;

namespace Kiva7.ValueConverter
{
    public class ToAmountValueConverter : IValueConverter
    {

        private string format = "#,##0";

        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            if (value is double)
            {
                return "$ " + ((double)value).ToString(format, culture);
            }
            else if (value is double? && ((double?)value).HasValue)
            {
                return "$ " + ((double?)value).Value.ToString(format, culture);
            }
            else
                return null;
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}
